package cn.flightcloud.auth.config.oauth;

import java.util.ArrayList;
import java.util.List;

import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.ClientDetailsService;
import org.springframework.security.oauth2.provider.ClientRegistrationException;
import org.springframework.security.oauth2.provider.client.BaseClientDetails;


public class ClientDetailsServiceImpl implements ClientDetailsService{

	@Override
	public ClientDetails loadClientByClientId(String clientId) throws ClientRegistrationException {
		BaseClientDetails clientDetails = new BaseClientDetails();
		clientDetails.setClientId(clientId);
		List<String> authorizedGrantTypes = new ArrayList<>();
		authorizedGrantTypes.add("client_credentials");
		authorizedGrantTypes.add("refresh_token");
		authorizedGrantTypes.add("authorization_code");
		clientDetails.setAuthorizedGrantTypes(authorizedGrantTypes);

		List<String> scopes = new ArrayList<>();
		scopes.add("select");
		clientDetails.setScope(scopes);
		return clientDetails;
	}

}
